<template>
    <div class="photoinfo-container">
        <h3>{{photoinfo.description}}</h3>
        <p class="subtitle">
            <span>发表时间: {{photoinfo.ctime}}</span>
            <span>点击: 0次</span>
        </p>

        <hr>

        <!-- 缩略图区域 -->
           <!-- <img class="preview-img" v-for="item in list" :key="item.EnName" :src="item.EnName" height="100" @click="$preview.open(index, list)">                -->
           <div class="thumbs">
           <vue-preview :slides="slide1" @close="handleClose"></vue-preview>
           </div>
        <!-- 图片内容区 -->
        <div class="content" v-html="photoinfo.title"></div>
        <!-- 放置一个现成的评论子组件 -->
        <cmt-box :id="id"></cmt-box>
    </div>
</template>

<script>
import comment from '../subcomponents/comment.vue'

export default {
    data(){
        return {
            key: '2667587171c7012add10a01160b7216c',
            id: this.$route.params.id,
            photoinfo: {},
            //list: []
            slide1: []
        }
    },
    created() {
        this.getPhotoInfo();
        this.getThumbs();
        this.handleClose();
    },
    methods: {
        getPhotoInfo(){

            this.$http.get("http://api.tianapi.com/guonei/index?key=" + this.key + "&num=10")
			.then(result => {
				console.log(result.body)
				if(result.body.code == 200) {
					//result.body.newslist.unshift({ title: '全部', ctime: '2020-05-18 22:00', })
					this.photoinfo = result.body.newslist[this.id]
                }
            })

        },
        getThumbs() {
            let _this =  this 
             _this.$axios.get('http://localhost:3000/slt')
            .then(res => {
                        if(res.status === 200 && res.data.code === 0) {
                            // res.data.obj.forEach(item=>{
                            //     item.msrc = item.src
                            // })
                            _this.slide1 = res.data.obj
                            console.log(_this.slide1)
                        }
                        
               
            })
        },  
        handleClose(){
            console.log('close event')
        }
        
    },
    components:{
        'cmt-box' : comment
    }
       
}
</script>

<style lang="scss" scoped>
.photoinfo-container{
    padding: 3px;
    h3{
        color: #26a2ff;
        font-size: 15px;
        text-align: center;
        margin: 15px 0;
    }
    .subtitle{
        display: flex;
        justify-content: space-between;
        font-size: 13px;
    }

    .content{
        font-size: 14px;
        line-height: 30px;
    }

    .thumbs{
                /deep/ .my-gallery{   //deep深层作用选择器
                    display: flex;
                    flex-wrap:wrap;//默认换行
                    figure{
                        width: 30%;
                        margin: 5px;
                        img{
                            width: 100%;
                            box-shadow: 0 0 8px #999;
                            border-radius: 5px;
                        }
                    }
                }
            }
}
</style>